﻿namespace SocketCore.Common.Event;

public class SocketEventArgs(SocketEventType type, object data) : EventArgs
{
    /// <summary>
    /// 事件类型
    /// </summary>
    public SocketEventType Type { get; } = type;

    /// <summary>
    /// 事件数据
    /// </summary>
    public object Data { get; } = data;

    /// <summary>
    /// 时间
    /// </summary>
    public DateTimeOffset DateTime { get; } = DateTimeOffset.Now;

    /// <summary>
    /// 转换数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public T? GetData<T>() where T : class
    {
        return Data as T;
    }
}